package com.fenghuajueli.libbasecoreui.utils;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;

import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.LogUtils;

import java.util.List;
import java.util.Random;

/**
 * ===========================================================
 * author：songpeng on 2/19/21 15:48
 * email：fenghuajueli@gmail.com
 * ===========================================================
 * 一些通用的判断方法
 */
public class CommonUtils {

    /**
     * 检测是否安装支付宝
     *
     * @param context
     * @return
     */
    public static boolean checkAliPayInstalled(Context context) {
        return AppUtils.isAppInstalled("com.eg.android.AlipayGphone");
    }

    /**
     * 判断 用户是否安装微信客户端
     */
    public static boolean isWeixinAvilible(Context context) {
        return AppUtils.isAppInstalled("com.tencent.mm");
    }

    /**
     * 判断 用户是否安装QQ客户端
     */
    public static boolean isQQClientAvailable(Context context) {
        return AppUtils.isAppInstalled("com.tencent.qqlite") || AppUtils.isAppInstalled("com.tencent.mobileqq");
    }

    public static String getBaketName(Context context){
        String baketname = "";
        String packageName = context.getPackageName();
        System.out.println("packageName======"+packageName);
        baketname = packageName.replaceAll("\\.","-");
        return baketname;
    }

    public static String getSixtenFourNumber(int max) {
        int  maxNum = 36;
        int i;
        int count = 0;
        char[] str = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
                'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
                'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ,'=','+',};
        StringBuffer pwd = new StringBuffer("");
        Random r = new Random();
        while(count < max){
            i = Math.abs(r.nextInt(maxNum));
            if (i >= 0 && i < str.length) {
                pwd.append(str[i]);
                count ++;
            }
        }
        return pwd.toString();
    }
}
